package sis.report;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-23 08:48
 * @notify
 * @version 1.0
 */

import sis.studentinfo.Student;

import java.util.EnumMap;
import java.util.Map;

public class ReportCard {
    public static final String A_MESSAGE = "第一名";
    public static final String B_MESSAGE = "第二名";
    public static final String C_MESSAGE = "第三名";
    public static final String D_MESSAGE = "第四名";

    private Map<Student.Grade, String> message = null;

    //通过key获取map的值
    public String getMessage(Student.Grade grade) {
        return getMessages().get(grade);
    }

    public Map<Student.Grade, String> getMessages() {
        //如果map为null 就加载
        if (message == null) {
            loadMessages();
        }
        return message;
    }

    //延迟加载
    private void loadMessages() {
        message = new EnumMap<Student.Grade, String>(Student.Grade.class);
        message.put(Student.Grade.A, A_MESSAGE);
        message.put(Student.Grade.B, B_MESSAGE);
        message.put(Student.Grade.C, C_MESSAGE);
        message.put(Student.Grade.D, D_MESSAGE);
    }
}
